home *** CD-ROM | disk | FTP | other *** search
/ Chip 2006 June / CHIP 2006-06.2.iso / program / driver / 6-4_xp-2k_dd_cc.exe / Data1.cab / _A92767CE99104F1888D9EE0DDBF47A95 < prev    next >
Encoding:
Text File  |  2003-09-15  |  9.4 KB  |  347 lines

  1. // Copyright (c) 2000-2003 Quadralay Corporation.  All rights reserved.
  2. //
  3.  
  4. function  WWHBook_Object(ParamDirectory)
  5. {
  6.   // Set values from callbacks
  7.   //
  8.   this.mDirectory = null;
  9.   this.mTitle     = null;
  10.   this.mContext   = null;
  11.   this.mFiles     = new WWHFileList_Object();
  12.   this.mPopups    = new WWHPopupHash_Object();
  13.  
  14.   // Fix up directory
  15.   //
  16.   if (ParamDirectory == ".")
  17.   {
  18.     this.mDirectory = "";
  19.   }
  20.   else
  21.   {
  22.     this.mDirectory = ParamDirectory + "/";
  23.   }
  24.  
  25.   this.fInit = WWHBook_Init;
  26. }
  27.  
  28. function  WWHBook_Init(ParamTitle,
  29.                        ParamContext,
  30.                        ParamFilesFunction,
  31.                        ParamPopupsFunction,
  32.                        ParamALinksFunction)
  33. {
  34.   this.mTitle   = ParamTitle;
  35.   this.mContext = ParamContext;
  36.  
  37.   // Load files
  38.   //
  39.   ParamFilesFunction(this.mFiles);
  40.  
  41.   // Load popups
  42.   //
  43.   ParamPopupsFunction(this.mPopups);
  44.  
  45.   // Load alinks
  46.   //
  47.   ParamALinksFunction(WWHFrame.WWHALinks);
  48. }
  49.  
  50. function  WWHBookList_Object()
  51. {
  52.   this.mInitIndex = 0;
  53.   this.mBookList  = new Array();
  54.  
  55.   this.fInit_AddBookDir                = WWHBookList_Init_AddBookDir;
  56.   this.fInit_BookData_Script           = WWHBookList_Init_BookData_Script;
  57.   this.fInit_AddBook                   = WWHBookList_Init_AddBook;
  58.   this.fInit_IncrementIndex            = WWHBookList_Init_IncrementIndex;
  59.   this.fGetBookTitle                   = WWHBookList_GetBookTitle;
  60.   this.fHREFToFileIndex                = WWHBookList_HREFToFileIndex;
  61.   this.fHREFToTitle                    = WWHBookList_HREFToTitle;
  62.   this.fBookIndexFileIndexToTitle      = WWHBookList_BookIndexFileIndexToTitle;
  63.   this.fGetBookIndexFileHREF           = WWHBookList_GetBookIndexFileHREF;
  64.   this.fBookFileIndiciesToHREF         = WWHBookList_BookFileIndiciesToHREF;
  65.   this.fHREFToBookIndexFileIndexAnchor = WWHBookList_HREFToBookIndexFileIndexAnchor;
  66.   this.fGetSyncPrevNext                = WWHBookList_GetSyncPrevNext;
  67.   this.fGetContextBook                 = WWHBookList_GetContextBook;
  68.   this.fIsPopupClickable               = WWHBookList_IsPopupClickable;
  69.   this.fGetPopupHTML                   = WWHBookList_GetPopupHTML;
  70. }
  71.  
  72. function  WWHBookList_Init_AddBookDir(ParamBookDir)
  73. {
  74.   this.mBookList[this.mBookList.length] = new WWHBook_Object(ParamBookDir);
  75. }
  76.  
  77. function  WWHBookList_Init_BookData_Script()
  78. {
  79.   var  Scripts  = new WWHStringBuffer_Object();
  80.   var  MaxIndex = 0;
  81.   var  Index    = 0;
  82.   var  BookDirectory;
  83.  
  84.  
  85.   this.mInitIndex = 0;
  86.   for (MaxIndex = this.mBookList.length, Index = 0 ; Index < MaxIndex ; Index++)
  87.   {
  88.     BookDirectory = WWHFrame.WWHHelp.mHelpURLPrefix + WWHFrame.WWHBrowser.fRestoreEscapedSpaces(this.mBookList[Index].mDirectory);
  89.  
  90.     Scripts.fAppend("<script type=\"text/javascript\" language=\"JavaScript1.2\" src=\"" + BookDirectory + "wwhdata/common/title.js\"></script>\n");
  91.     Scripts.fAppend("<script type=\"text/javascript\" language=\"JavaScript1.2\" src=\"" + BookDirectory + "wwhdata/common/context.js\"></script>\n");
  92.     Scripts.fAppend("<script type=\"text/javascript\" language=\"JavaScript1.2\" src=\"" + BookDirectory + "wwhdata/common/files.js\"></script>\n");
  93.     Scripts.fAppend("<script type=\"text/javascript\" language=\"JavaScript1.2\" src=\"" + BookDirectory + "wwhdata/common/popups.js\"></script>\n");
  94.     Scripts.fAppend("<script type=\"text/javascript\" language=\"JavaScript1.2\" src=\"" + BookDirectory + "wwhdata/common/alinks.js\"></script>\n");
  95.  
  96.     Scripts.fAppend("<script type=\"text/javascript\" language=\"JavaScript1.2\" src=\"" + WWHFrame.WWHHelp.mHelpURLPrefix + "wwhelp/wwhimpl/common/scripts/bklist1s.js\"></script>\n");
  97.   }
  98.  
  99.   return Scripts.fGetBuffer();
  100. }
  101.  
  102. function  WWHBookList_Init_AddBook(ParamTitle,
  103.                                    ParamContext,
  104.                                    ParamFilesFunction,
  105.                                    ParamPopupsFunction,
  106.                                    ParamALinksFunction)
  107. {
  108.   // Update book information
  109.   //
  110.   this.mBookList[this.mInitIndex].fInit(ParamTitle, ParamContext,
  111.                                         ParamFilesFunction,
  112.                                         ParamPopupsFunction,
  113.                                         ParamALinksFunction);
  114. }
  115.  
  116. function  WWHBookList_Init_IncrementIndex()
  117. {
  118.   this.mInitIndex++;
  119. }
  120.  
  121. function  WWHBookList_GetBookTitle(ParamIndex)
  122. {
  123.   return this.mBookList[ParamIndex].mTitle;
  124. }
  125.  
  126. function  WWHBookList_HREFToFileIndex(ParamIndex,
  127.                                       ParamHREF)
  128. {
  129.   return this.mBookList[ParamIndex].mFiles.fHREFToIndex(ParamHREF);
  130. }
  131.  
  132. function  WWHBookList_HREFToTitle(ParamIndex,
  133.                                   ParamHREF)
  134. {
  135.   return this.mBookList[ParamIndex].mFiles.fHREFToTitle(ParamHREF);
  136. }
  137.  
  138. function  WWHBookList_BookIndexFileIndexToTitle(ParamBookIndex,
  139.                                                 ParamFileIndex)
  140. {
  141.   return this.mBookList[ParamBookIndex].mFiles.fFileIndexToTitle(ParamFileIndex);
  142. }
  143.  
  144. function  WWHBookList_GetBookIndexFileHREF(ParamHREF)
  145. {
  146.   var  ResultArray = new Array(-1, null);
  147.   var  LongestMatchIndex;
  148.   var  MaxIndex;
  149.   var  Index;
  150.   var  Parts;
  151.   var  FileHREF;
  152.  
  153.  
  154.   // Find the book directory
  155.   //
  156.   LongestMatchIndex = -1;
  157.   for (MaxIndex = this.mBookList.length, Index = 0 ; Index < MaxIndex ; Index++)
  158.   {
  159.     if (ParamHREF.indexOf(this.mBookList[Index].mDirectory) == 0)
  160.     {
  161.       if (LongestMatchIndex == -1)
  162.       {
  163.         LongestMatchIndex = Index;
  164.       }
  165.       else if (this.mBookList[Index].mDirectory.length > this.mBookList[LongestMatchIndex].mDirectory.length)
  166.       {
  167.         LongestMatchIndex = Index;
  168.       }
  169.     }
  170.   }
  171.  
  172.   // If LongestMatchIndex is valid, we found our book directory
  173.   //
  174.   if (LongestMatchIndex != -1)
  175.   {
  176.     // Set FileHREF to be just the file portion
  177.     //
  178.     if (this.mBookList[LongestMatchIndex].mDirectory.length > 0)
  179.     {
  180.       FileHREF = ParamHREF.substring(this.mBookList[LongestMatchIndex].mDirectory.length, ParamHREF.length);
  181.     }
  182.     else
  183.     {
  184.       FileHREF = ParamHREF;
  185.     }
  186.  
  187.     ResultArray[0] = LongestMatchIndex;
  188.     ResultArray[1] = FileHREF;
  189.   }
  190.  
  191.   return ResultArray;
  192. }
  193.  
  194. function  WWHBookList_BookFileIndiciesToHREF(ParamBookIndex,
  195.                                              ParamFileIndex)
  196. {
  197.   return this.mBookList[ParamBookIndex].mDirectory + this.mBookList[ParamBookIndex].mFiles.fFileIndexToHREF(ParamFileIndex);
  198. }
  199.  
  200. function  WWHBookList_HREFToBookIndexFileIndexAnchor(ParamHREF)
  201. {
  202.   var  ResultArray = new Array(-1, -1, "");
  203.   var  Parts;
  204.   var  TrimmedHREF;
  205.   var  Anchor;
  206.   var  BookIndex;
  207.   var  FileIndex;
  208.  
  209.  
  210.   // Record anchor
  211.   //
  212.   Parts = ParamHREF.split("#");
  213.   TrimmedHREF = Parts[0];
  214.   Anchor = "";
  215.   if (Parts.length > 1)
  216.   {
  217.     if (Parts[1].length > 0)
  218.     {
  219.       Anchor = Parts[1];
  220.     }
  221.   }
  222.  
  223.   // Determine book index
  224.   //
  225.   Parts = this.fGetBookIndexFileHREF(TrimmedHREF);
  226.   if (Parts[0] >= 0)
  227.   {
  228.     BookIndex = Parts[0];
  229.     FileIndex = this.fHREFToFileIndex(BookIndex, escape(Parts[1]));
  230.  
  231.     if (FileIndex >= 0)
  232.     {
  233.       ResultArray[0] = BookIndex;
  234.       ResultArray[1] = FileIndex;
  235.       ResultArray[2] = Anchor;
  236.     }
  237.   }
  238.  
  239.   return ResultArray;
  240. }
  241.  
  242. function  WWHBookList_GetSyncPrevNext(ParamHREF)
  243. {
  244.   var  ResultArray = new Array(null, null, null);
  245.   var  Parts;
  246.   var  BookIndex;
  247.   var  FileIndex;
  248.  
  249.  
  250.   // Determine current book index and file index
  251.   //
  252.   Parts = this.fHREFToBookIndexFileIndexAnchor(ParamHREF);
  253.   BookIndex = Parts[0];
  254.   FileIndex = Parts[1];
  255.  
  256.   // Set return results
  257.   //
  258.   if ((BookIndex >= 0) &&
  259.       (FileIndex >= 0))
  260.   {
  261.     // Set sync
  262.     //
  263.     ResultArray[0] = ParamHREF;  // Indicates file found, sync possible
  264.  
  265.     // Set previous
  266.     //
  267.     if (FileIndex > 0)
  268.     {
  269.       ResultArray[1] = this.fBookFileIndiciesToHREF(BookIndex, FileIndex - 1);
  270.     }
  271.     else
  272.     {
  273.       if (BookIndex > 0)
  274.       {
  275.         ResultArray[1] = this.fBookFileIndiciesToHREF(BookIndex - 1, this.mBookList[BookIndex - 1].mFiles.mFileList.length - 1);
  276.       }
  277.     }
  278.  
  279.     // Set next
  280.     //
  281.     if ((FileIndex + 1) < this.mBookList[BookIndex].mFiles.mFileList.length)
  282.     {
  283.       ResultArray[2] = this.fBookFileIndiciesToHREF(BookIndex, FileIndex + 1);
  284.     }
  285.     else
  286.     {
  287.       if (((BookIndex + 1) < this.mBookList.length) &&
  288.           (this.mBookList[BookIndex + 1].mFiles.mFileList.length > 0))
  289.       {
  290.         ResultArray[2] = this.fBookFileIndiciesToHREF(BookIndex + 1, 0);
  291.       }
  292.     }
  293.   }
  294.  
  295.   return ResultArray;
  296. }
  297.  
  298. function  WWHBookList_GetContextBook(ParamContext)
  299. {
  300.   var  ResultBook = null;
  301.   var  MaxIndex;
  302.   var  Index;
  303.  
  304.  
  305.   for (MaxIndex = this.mBookList.length, Index = 0 ; Index < MaxIndex ; Index++)
  306.   {
  307.     if (this.mBookList[Index].mContext == ParamContext)
  308.     {
  309.       ResultBook = this.mBookList[Index];
  310.     }
  311.   }
  312.  
  313.   return ResultBook;
  314. }
  315.  
  316. function  WWHBookList_IsPopupClickable(ParamContext,
  317.                                        ParamLink)
  318. {
  319.   var  bPopupClickable = false;
  320.   var  Book;
  321.  
  322.  
  323.   Book = this.fGetContextBook(ParamContext)
  324.   if (Book != null)
  325.   {
  326.     bPopupClickable = Book.mPopups.fIsPopupClickable(ParamLink);
  327.   }
  328.  
  329.   return bPopupClickable;
  330. }
  331.  
  332. function  WWHBookList_GetPopupHTML(ParamContext,
  333.                                    ParamLink)
  334. {
  335.   var  PopupHTML = null;
  336.   var  Book;
  337.  
  338.  
  339.   Book = this.fGetContextBook(ParamContext)
  340.   if (Book != null)
  341.   {
  342.     PopupHTML = Book.mPopups.fGetPopupHTML(ParamLink);
  343.   }
  344.  
  345.   return PopupHTML;
  346. }
  347.